<template>
  <div id="app">
    <router-view v-if="isRouterAlive"/>
  </div>
</template>

<script>
import {circuiar_list} from "@/api/api";

export default {
  name: 'app',
  data() {
    return {
      notices: "",
      isRouterAlive: true,
      notifyPromise: Promise.resolve()
    }
  },
  created() {
    this.circuiar_lists()
  },
  provide() {
    return {
      reload: this.reload
    };
  },
  methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(() => {
        this.isRouterAlive = true;
      });
    },
    notify(node) {
      this.notifyPromise = this.notifyPromise.then(this.$nextTick).then(() => {
        this.$notify({
          title: '商家最新公告！',
          message: node,
          duration: 0
        });
      })
    },
    circuiar_lists() {
      circuiar_list().then(res => {
        if (res.Status == 200) {
          this.notices = res.Data
          console.log(this.notices);
          this.notices.forEach((item) => {
            this.notify(item.note)
          })
        }
      })
    },
    open2(node) {
      console.log(node);
      this.$nextTick(() => {
        this.$notify({
          title: '商家最新公告！',
          message: node,
          duration: 0
        });
      });
    },
  },
}
</script>

<style lang="scss">
@import '~@/assets/style/public-class.scss';
</style>
